function format(name) {
  // write code here
  let res = "";
  let length = name.length;
  for (let i = 0; i < length; i++) {
    if (name[i] == "_") {
      res += name[i + 1].toUpperCase();
      i++;
    } else if (name[i] >= "A" && name[i] <= "Z") {
      if (i == 0) {
        res += name[i].toLowerCase();
      } else if (name[i - 1] >= "A" && name[i - 1] <= "Z") {
        res += name[i].toLowerCase();
      }
    } else res += name[i];
  }
  return res;
}

let name = "TESTt_vari_able";
let res = format(name);
console.log(res);

console.log(name.toLowerCase());
